package BookStore.dao;

import BookStore.model.User;
import BookStore.util.UDbUtil;
import BookStore.view.U_Frame;

import javax.swing.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class ULoginDao {
    String name;
    String pswd;

    public ULoginDao(User user) {
        name = user.getUserName();
        pswd = user.getUserPsw();

    }
    public void ligin() throws Exception {
        Connection con = UDbUtil.getCon();
        Statement statement = con.createStatement();

        String sql = "select * from jdbc where name = '" + name + "' and psw = '" + pswd + "'";
        ResultSet resultSet = statement.executeQuery(sql);
        if (resultSet.next()) {
            new U_Frame().Uframe();
        } else {
            JOptionPane.showMessageDialog(null, "用户名或密码错误");

        }
    }

}

